package cn.biplam.front.component.view.systemManage.datasource.callback;

import cn.biplam.common.client.DataFilter;
import cn.biplam.common.client.Operator;
import cn.biplam.common.client.OperatorResult;
import cn.biplam.common.opcode.mdManage.TypeCode.ModelTypeCode;
import cn.biplam.common.struc.MdStruc;
import cn.biplam.common.tools.TOOLS;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.Result;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.callback.CallBack;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.template.base.Text;

/**
 * 数据源管理-模型类型绑定器
 * @author Wangsong 2009-6-22下午03:59:24
 * @version 1.0
 */
public class DbSourceModelTypeCallBack implements CallBack{

	public HtmlWindow[] getGroup(Result data, String homeUrl, UserInfo mUser)
	throws ErrorMessage {
		HtmlWindow[] opetator=new HtmlWindow[1];

		/** 模型类型ID */
		String typeId = data.getString(MdStruc.DbSourStruc.MODEL_TYPE);
		
		/** 取数据库类型*/
		DataFilter filter = new DataFilter();
		filter.put(MdStruc.MdTypeStruc.MODEL_TYPE_ID, typeId);
		OperatorResult sr = Operator.get(ModelTypeCode.Select_Model_Type_By_ID, mUser.getUserID(), filter);
		if(TOOLS.exist(sr)){
			typeId = sr.getValue(MdStruc.MdTypeStruc.MODEL_TYPE_DESC);
		}
		
		opetator[0]= new Text(typeId).get(); 
		opetator[0].setLength(TOOLS.getTextLength(typeId));
		return opetator;
	}

}
